package com.leo.entity;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Transient;

@Entity
public class Student implements Serializable {

	private static final long serialVersionUID = 1L;

	@Transient
	public static int nowVersionTime(){
		return (int) (new Date().getTime()/24/60/60/1000);
	}

	public Student(Student stu){
		this.className = stu.className;
		this.college =  stu.college;
		this.stuID = stu.stuID;
	}
	
	//班级
	@Column(length=40)
	private String className;

	//学院
	@Column(length=30)
	private String college;

	//入学时间
	@Column(length=10)
	private String entranceDate;

	//年级
	@Column(length=10)
	private String grade;

	//学号
	@Id
	@Column(length=15)
	private String stuID;

	//姓名
	@Column(length=20)
	private String name;

	//密码
	@Column(length=20)
	private String password;

	//电话
	@Column(length=15)
	private String phone;

	//专业
	@Column(length=20)
	private String professional;

	//性别
	@Column(length=5)
	private String sex;
	
	//dataVersion
	@Column(length=7)
	private Integer versionTime;

	@OneToMany(fetch=FetchType.LAZY,mappedBy="student")
	private List<Score> Scores = new ArrayList<Score>();

	public String getPassword() {
		return password;
	}


	public void setPassword(String password) {
		this.password = password;
	}


	public Integer getVersionTime() {
		return versionTime;
	}


	public void setVersionTime(Integer vertionTime) {
		this.versionTime = vertionTime;
	}


	public Student() {
		
	}

	
	public String getClassName() {
		return className;
	}

	public String getCollege() {
		return college;
	}

	public String getEntranceDate() {
		return entranceDate;
	}

	public String getGrade() {
		return grade;
	}
	
	public String getStuID() {
		return stuID;
	}

	public String getName() {
		return name;
	}


	public String getPhone() {
		return phone;
	}

	public String getProfessional() {
		return professional;
	}

	public String getSex() {
		return sex;
	}
	
	public void setClassName(String className) {
		this.className = className;
	}

	public void setCollege(String college) {
		this.college = college;
	}

	public void setEntranceDate(String entranceDate) {
		this.entranceDate = entranceDate;
	}

	public void setGrade(String grade) {
		this.grade = grade;
	}

	public void setStuID(String stuID) {
		this.stuID = stuID;
	}
	
	public void setName(String name) {
		this.name = name;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}
	
	public void setProfessional(String professional) {
		this.professional = professional;
	}
	
	public void setSex(String sex) {
		this.sex = sex;
	}
	
	
	@Override
	public String toString(){
		return name + "," + stuID;
	}

	public void setScores(List<Score> scores) {
		Scores = scores;
	}

	public List<Score> getScores() {
		return Scores;
	}

}
